/*
 * @Description: connect中间件--logger
 * @Author: your name
 * @Date: 2019-08-19 13:58:18
 * @LastEditTime: 2019-08-20 15:43:12
 * @LastEditors: Please set LastEditors
 */

 const connect = require('connect')
 const morgan = require('morgan')
 const cookieParser = require('cookie-parser')
 const cookieSession = require('cookie-session')
 const basicAuto = require('basic-auth')
 const bodyParser = require('body-parser')
 const directory = require('directory')

 const app = connect().use(morgan('dev')).use(cookieParser('ls love xq')).use(bodyParser()).use(cookieSession({ secret: 'adddaa!', cookie: { maxAge: 60 * 60 * 1000 }})).use(directory(__dirname)).use(function(req,res){
    // const credentials  = basicAuto(req)
    // if (!credentials || !check(credentials.name, credentials.pass)) {
    //     console.log(JSON.stringify(credentials))
    //     res.statusCode = 401
    //     res.setHeader('WWW-Authenticate', 'Basic realm="example"')
    //     res.end('Access denied') 
    //   } else {
    //     res.end('Access granted')
    //   }

    res.end(JSON.stringify(req.body))

 }).listen(3000)



